//
//  ViewController.m
//  UIImageView
//
//  Created by caimengjun on 16/12/10.
//  Copyright © 2016年 caimengjun. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.imageView.image = [UIImage imageNamed:@"photo1"];//为image指定图片在assets中
    
    
    //在supporting files 中指定图片。
//    NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"photo2" ofType:@"jpg"];
//    self.imageView.image = [UIImage imageWithContentsOfFile:imagePath];
    
    //修饰图片的边角。
    self.imageView.layer.cornerRadius = 120;  // cornerRadius是为 半弧形 的。  另 数字等于图片大小的一半 则 表示为 圆形。
    self.imageView.layer.masksToBounds=YES;
    
    
    //边框border
    self.imageView.layer.borderWidth = 5;
    self.imageView.layer.borderColor =[UIColor redColor].CGColor;
    
    //图片的点击的操作  点击实现 tap 方法
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
    [self.imageView addGestureRecognizer:tap];
    
    //用户交互
    self.imageView.userInteractionEnabled=YES;
}
    //实现 tap 方式 的 代码 提醒框
-(void) tap:(UITapGestureRecognizer *) sender {
    //UIAlertView *alertView = [[UIAlertView alloc］initWithTitle:@"提醒" message:@"点击了图片" delegate :nil  cancelButtonTiTle :nil  otherButtonTitles:@"OK", nil];
   // [alertView show];
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"按钮被点击了" preferredStyle:  UIAlertControllerStyleAlert];
    
    [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        //点击按钮的响应事件；
    }]];
    
    //弹出提示框；
    [self presentViewController:alert animated:true completion:nil];
    }
    
    



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
